/** @file
 *  @par License 
 *  Copyright (C) 2010-2011 Intel Corporation. All Rights Reserved.
 *  
 **/

#ifndef KEN_GENERAL_KERNEL_STUB_INTERNAL_H
#define KEN_GENERAL_KERNEL_STUB_INTERNAL_H

#pragma warning(disable:4201)   // nameless struct/union
#pragma warning(disable:4127)   // do {} while (0)

#include <ntifs.h>              // SetFlag, ClearFlag
#include <ntddk.h>
#include <wdf.h>

#include <syspy/types.h>
#include <driverbase/log.h>
#include <driverbase/io.h>
//
// Macro/structure definitions
//
#define KS_NT_DEVICE_NAME  L"\\Device\\kstub"
#define KS_DOS_DEVICE_NAME L"\\DosDevices\\kstub"
#define KS_TAG             'KSTB'


typedef struct _GS_DEVICE_EXTENSION {
    PDEVICE_OBJECT      DeviceObject;
} KS_DEVICE_EXTENSION, *PKS_DEVICE_EXTENSION;

WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(KS_DEVICE_EXTENSION, KSGetData)

//
// Module's Function Declaration 
//
DRIVER_INITIALIZE                       DriverEntry;
EVT_WDF_DRIVER_UNLOAD                   KSDriverUnload;
EVT_WDF_DEVICE_CONTEXT_CLEANUP          KSEvtDriverContextCleanup;
EVT_WDF_DEVICE_SHUTDOWN_NOTIFICATION    KSEvtDeviceShutdown;
EVT_WDF_DEVICE_FILE_CREATE              KSEvtDeviceCreate;
EVT_WDF_FILE_CLOSE                      KSEvtDeviceClose;
EVT_WDF_IO_QUEUE_IO_DEVICE_CONTROL      KSEvtIoDeviceControl;
EVT_WDF_IO_QUEUE_IO_READ                KSEvtIoRead;
EVT_WDF_IO_QUEUE_IO_WRITE               KSEvtIoWrite;


NTSTATUS
KSDeviceAdd(
    IN WDFDRIVER Driver,
    IN PWDFDEVICE_INIT DeviceInit
    );

NTSTATUS
KSMmIoRead (
    u32_t base,
    u32_t length,
    u8_t  *output,
    u32_t *output_length
    );

NTSTATUS
KSIoWrite (
    u32_t port,
    u32_t width,
    u32_t value
    );

NTSTATUS
KSIoRead (
    u32_t port,
    u32_t width,
    u8_t  *output,
    u32_t *output_length
    );

NTSTATUS
KSIoPortRead(
    u32_t index_port,
    u32_t data_port,
    u8_t* buffer
    );

NTSTATUS
KSMmIoScan(
    u32_t start,                 ///< start address for scan range
    u32_t length,                ///< length for scan range
    u8_t  *scan_buffer,          ///< the buffer for 
    u32_t scan_buffer_len,
    u32_t *first
    );

#endif // TD_SLEEP_COUNT_INTERNAL_H
